package com.nageoffer.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.shortlink.project.dao.entity.ShortLinkDO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkPageReqDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

/**
 * 短链接持久层
 */
public interface ShortLinkMapper extends BaseMapper<ShortLinkDO> {

    /**
     * 访问统计自增
     */
    @Insert("update tb_link set total_pv = total_pv + #{totalPv},total_uv = total_uv+#{totalUv},total_uip = total_uip+#{totalUip} where gid = #{gid} and full_short_uri = #{fullShortUri}")
    void incrementStats(@Param("gid")String gid, @Param("fullShortUri")String fullShortUri, @Param("totalPv")int totalPv, @Param("totalUv")int totalUv, @Param("totalUip")int totalUip);


    IPage<ShortLinkDO> pageLink(ShortLinkPageReqDTO requestParam);

}
